package com.example.volly;

import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.BaseAdapter;
import android.widget.TextView;
import java.util.List;

public class MyAdapater extends BaseAdapter {
    private static final String TAG = "MyAdapter";
    MainActivity contenxt;
    List<Bean.ResultBean.DataBean> list;

    public MyAdapater(MainActivity contenxt, List<Bean.ResultBean.DataBean> list) {
        this.contenxt = contenxt;
        this.list = list;
    }

    @Override
    public int getCount() {
        Log.e(TAG,""+list.size());
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null){
            convertView = View.inflate(contenxt, R.layout.item_layout,null);
        }
        WebView mIvImage = convertView.findViewById(R.id.imag);
        TextView mTvTime = convertView.findViewById(R.id.time);
        TextView mTvTitle = convertView.findViewById(R.id.title);
        mTvTitle.setText(list.get(position).getTitle());
        mTvTime.setText(list.get(position).getDate());
        mIvImage.loadUrl(list.get(position).getThumbnail_pic_s());
        return convertView;
    }
}
